package com.youku.baseUI
{
   import fl.controls.Button;
   import flash.events.MouseEvent;
   import flash.events.KeyboardEvent;
   import flash.display.Sprite;
   
   public class BasePlayerButton extends Button
   {
      
      public function BasePlayerButton() {
         super();
         this._offsetText = true;
         this._fixLeftAlign = -1;
         this._hardOffset = 0;
         this._hoverFilters = null;
         this._upFilters = null;
         setStyle("focusRectSkin",new Sprite());
      }
      
      private var _fixLeftAlign:Number;
      
      private var _offsetText:Boolean;
      
      private var _hardOffset:Number;
      
      private var _hoverFilters:Array;
      
      private var _upFilters:Array;
      
      public function setFilterEffect(param1:Array = null, param2:Array = null) : void {
         this._hoverFilters = param1;
         this._upFilters = param2;
         if(!(this._hoverFilters == null) && !(this._upFilters == null) && this._hoverFilters.length > 0 && this._upFilters.length > 0)
         {
            this.addEventListener(MouseEvent.MOUSE_OVER,this.onButtonEffectEvent,false,0,true);
            this.addEventListener(MouseEvent.MOUSE_OUT,this.onButtonEffectEvent,false,0,true);
         }
         else
         {
            this.removeEventListener(MouseEvent.MOUSE_OVER,this.onButtonEffectEvent);
            this.removeEventListener(MouseEvent.MOUSE_OUT,this.onButtonEffectEvent);
         }
      }
      
      public function set fixLeftAlign(param1:Number) : void {
         this._fixLeftAlign = param1;
         validateNow();
      }
      
      public function set offsetText(param1:Boolean) : void {
         this._offsetText = param1;
      }
      
      public function set hardOffset(param1:Number) : void {
         this._hardOffset = param1;
      }
      
      override protected function drawLayout() : void {
         var _loc1_:* = NaN;
         super.drawLayout();
         if(this._offsetText)
         {
            textField.y = textField.y + (textField.height - textField.textHeight) / 2;
         }
         if(this._fixLeftAlign >= 0)
         {
            _loc1_ = Number(getStyleValue("textPadding"));
            if(!(icon == null) && !(label == ""))
            {
               icon.x = this._fixLeftAlign;
               textField.x = icon.x + icon.width + _loc1_;
            }
            else if(icon != null)
            {
               icon.x = this._fixLeftAlign;
            }
            else if(label != "")
            {
               textField.x = this._fixLeftAlign;
            }
            
            
         }
         textField.y = textField.y + this._hardOffset;
         if(icon != null)
         {
            icon.x = Math.round(icon.x);
            icon.y = Math.round(icon.y);
         }
         textField.x = Math.round(textField.x);
         textField.y = Math.round(textField.y);
      }
      
      override protected function keyDownHandler(param1:KeyboardEvent) : void {
      }
      
      override protected function keyUpHandler(param1:KeyboardEvent) : void {
      }
      
      private function onButtonEffectEvent(param1:MouseEvent) : void {
         if(param1.type == MouseEvent.MOUSE_OVER)
         {
            this.filters = this._hoverFilters;
         }
         else if(param1.type == MouseEvent.MOUSE_OUT)
         {
            this.filters = this._upFilters;
         }
         
      }
   }
}
